package com.hellomeng.oop.statics;

public class StaticTest {
    public static void main(String[] args) {
        Circle c1 = new Circle();
        Circle c2 = new Circle();
        System.out.println("c1.id="+c1.getId()+" "+"当前共"+Circle.getTotal()+"个");
        //c1.id=1001 当前共2个
        System.out.println("c2.id="+c2.getId()+" "+"当前共"+Circle.getTotal()+"个");
        //c2.id=1002 当前共2个
    }
}


class Circle{
    private Double radius;
    private Integer id;
    private static Integer total = 0;   //一共造了多少个圆
    private static Integer init = 1001;    //当前圆的编号到哪里了，后面的圆从这里开始编号

    public Circle(){
        id = init++;
        total = total + 1;
    }

    public Double getRadius() {
        return radius;
    }
    public void setRadius(Double radius) {
        this.radius = radius;
    }
    public Integer getId() {
        return id;
    }
    public static Integer getTotal() {
        return total;
    }

}